package com.slipper.system.log.service;

import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import org.springframework.stereotype.Service;
import javax.annotation.Resource;

import com.slipper.system.log.dao.OperatorLogDao;
import com.slipper.system.api.log.bo.OperatorLogBO;

import com.slipper.common.transaction.ReadTransactional;
import com.slipper.common.transaction.WriteTransactional;
import com.slipper.common.util.Tool;

@Service
@ReadTransactional
public class OperatorLogService {
    @Resource
    private OperatorLogDao operatorLogDao;
    
    public OperatorLogBO queryBy(String id){
        return operatorLogDao.queryBy(id);
    }
    
    public List<OperatorLogBO> queryList(OperatorLogBO bo){
        return operatorLogDao.queryList(bo);
    }
    
    public PageInfo<OperatorLogBO> queryPage(OperatorLogBO bo){
        PageHelper.startPage(bo.getPageNumber(), bo.getPageSize());
        return new PageInfo<>(operatorLogDao.queryList(bo));
    }
    
    @WriteTransactional
    public int save(OperatorLogBO bo){
        int result;
        if (bo.getId() != null && !"".equals(bo.getId())) {
            result = operatorLogDao.update(bo);
        } else {
            bo.setId(Tool.getUUID());
            result = operatorLogDao.insert(bo);
        }
        return result;
    }
    
    @WriteTransactional
    public int delete(OperatorLogBO bo){
        return operatorLogDao.delete(bo);
    }
}
